var ES = ES || {};
ES.Reg = {
    EMAIL: /\w+([.-_]\w+)*@\w+([.-_]\w+)*\.\w{2,4}/,
    CN: /^[\u4e00-\u9fa5]*$/,
    EN: /^[a-zA-Z]*$/,
    NUM: /^[0-9]*$/,
    SINT: /^[1-9]\d*$/,
    SFLOAT: /^[1-9]\d*.\d*|0.\d*[1-9]\d*$/,
    MONEY: /^((([1-9]\d*)|0)(\.\d{1,2})?)$/
};
ES.BS = {
    Version: navigator.appVersion,
    Opera: !!window.opera,
    WebKit: navigator.userAgent.indexOf("AppleWebKit/") > -1,
    Gecko: navigator.userAgent.indexOf("Gecko") > -1 && navigator.userAgent.indexOf("KHTML") == -1,
    Win: navigator.userAgent.indexOf("Windows") >= 0
};
ES.Cookie = {
    setCookie: function (e, g, f, b, a, d) {
        var c = e + "=" + encodeURIComponent(g);
        f && (c += "; expires=" + f);
        b && (c += "; path=" + b);
        a && (c += "; domain=" + a);
        d && (c += "; secure");
        document.cookie = c
    },
    getCookie: function (c) {
        var b = "(?:; )?" + c + "=([^;]*);?";
        var a = new RegExp(b);
        if (a.test(document.cookie)) {
            return decodeURIComponent(RegExp["$1"])
        } else {
            return null
        }
    },
    delCookie: function (d, b, a) {
        var c = d + "=; expires=" + (new Date(0)).toGMTString();
        b && (c += "; path=" + b);
        a && (c += "; domain=" + a);
        document.cookie = c
    },
    getExpDate: function (d, a, c) {
        var b = new Date();
        if (typeof d === "number" && typeof a === "number" && typeof c === "number") {
            b.setDate(b.getDate() + parseInt(d));
            b.setHours(b.getHours() + parseInt(a));
            b.setMinutes(b.getMinutes() + parseInt(c));
            return b.toGMTString()
        }
    }
};
ES.Img = {
    loadCheck: function (d, c, a, e) {
        var b = new Image();
        d = ("string" === typeof d) ? d : "";
        c = (("number" === typeof c) ? c : 5) - 1;
        a = ("function" === typeof a) ? a : function () {
            return
        };
        e = ("function" === typeof e) ? e : function () {
            return
        };
        if (!!(window.attachEvent && !window.opera)) {
            b.onreadystatechange = function () {
                if (b.readyState == "complete" || b.readyState == "loaded") {
                    a()
                }
            }
        } else {
            b.onload = function () {
                if (b.complete == true) {
                    a()
                }
            }
        }
        b.onerror = function () {
            if (0 < c) {
                c--;
                this.src = undefined;
                this.onerror = null;
                this.onload = null;
                this.onreadystatechange = null;
                ES.Img.loadCheck(d, c, a, e)
            } else {
                this.onerror = null;
                this.onload = null;
                this.onreadystatechange = null;
                e()
            }
        };
        b.src = d
    },
    defalutImage: function (a, b) {
        ES.Img.loadCheck(b, 2,
        function () {
            a.src = b
        })
    }
};
ES.JSON = {
    parse: function (sJSON) {
        if (typeof JSON !== "undefined") {
            return JSON.parse(sJSON)
        } else {
            return eval("(" + sJSON + ")")
        }
    }
};
ES.Url = {
    getParams: function () {
        var a = window.location.search.substr(1);
        var c = {};
        if ("" != a) {
            a = a.split("&");
            for (var b = 0; b < a.length; b++) {
                c[a[b].split("=")[0]] = unescape(a[b].split("=")[1])
            }
        }
        return c
    },
    urlEncode: function (g) {
        var f = ["%25", "%26", "*", "%3F", "%3A", "%3C", "%3E", "%23", "%5C", "%2F", "%7C", "%22", "%2B", "_", "."];
        var b = ["%", "&", "*", "?", ":", ">", "<", "#", "\\", "/", "|", '"', "+", "_", "."];
        var e = encodeURIComponent(g.replace(/(^\s)|(\s$)/g, ""));
        for (var c = 0,
        a = f.length; c < a; c++) {
            var d = new RegExp("\\" + f[c], "ig");
            e = e.replace(d, "=" + b[c].charCodeAt(0).toString(16).toUpperCase())
        }
        return e
    },
    UrlDecode: function (g) {
        var f = ["%25", "%26", "*", "%3F", "%3A", "%3C", "%3E", "%23", "%5C", "%2F", "%7C", "%22", "%2B", "_", "."];
        var b = ["%", "&", "*", "?", ":", ">", "<", "#", "\\", "/", "|", '"', "+", "_", "."];
        var e = g;
        for (var c = 0,
        a = b.length; c < b.length; c++) {
            var d = new RegExp("=" + b[c].charCodeAt(0).toString(16).toUpperCase(), "ig");
            e = e.replace(d, f[c])
        }
        e = decodeURIComponent(e);
        return e
    }
};
ES.Tools = {};
if (typeof $ !== "undefined") {
    ES.Tools.selectChk = function (a, b) {
        a.click(function () {
            var c = $(this);
            if (c.attr("checked")) {
                a.attr("checked", "checked");
                b.not(":checked").attr("checked", "checked")
            } else {
                a.attr("checked", "");
                b.filter(":checked").attr("checked", "")
            }
        })
    };
    ES.Tools.filterInput = function (b, a) {
        b.keyup(function () {
            var c = $(this);
            c.val(c.val().replace(a, ""))
        })
    }
}
ES.Tools.stringFormat = function () {
    if (!arguments.length) {
        return null
    }
    var c = arguments[0],
    b = arguments.length - 1;
    for (var a = 1; a <= b; a++) {
        c = c.replace(/\#\{[\w-\s]*\}/, arguments[a])
    }
    return c
};
ES.Tools.getKeyCode = function (a) {
    return a.keyCode || a.which || a.charCode
};
ES.Maths = {
    formatFloat: function (a, b) {
        return Math.round(a * Math.pow(10, b)) / Math.pow(10, b)
    },
    formatNumber: function (b) {
        if (/[^0-9\.\-]/.test(b)) {
            return "0"
        }
        b = ES.Maths.formatFloat(b, 2);
        b = (b + "").replace(/^(\d*)$/, "$1.");
        b = (b + "00").replace(/(\d*\.\d\d)\d*/, "$1");
        b = b.replace(".", ",");
        var a = /(\d)(\d{3},)/;
        while (a.test(b)) {
            b = b.replace(a, "$1,$2")
        }
        b = b.replace(/,(\d\d)$/, ".$1");
        return b.replace(/^\./, "0.")
    },
    unFormatNumber: function (a) {
        return parseFloat(a.replace(/\,/g, ""))
    }
};
ES.CRM = ES.CRM || {};
ES.CRM.disableBtn = function () { };
ES.CRM.openPop = function (a) {
    a.btnBar = (undefined == a.btnBar ? false : a.btnBar);
    window.top.oWin = window;
    window.top.oDG = new $.dialog(a);
    window.top.oDG.ShowDialog();
    return window.top.oDG
};
ES.CRM.openChildPop = function (b) {
    var a = frameElement.lhgDG;
    window.top.oSWin = window;
    b.parent = a;
    b.childCallBack = b.childCallBack ||
    function () { };
    window.top.oSDG = new a.curWin.$.dialog(b);
    window.top.oSDG.ShowDialog();
    window.top.oSDG.childCallBack = b.childCallBack;
    return window.top.oSDG
};
ES.CRM.openAlert = function (c, a, d) {
    a = '<p style="margin:15px;">' + (a || "") + "</p>";
    var b = {
        id: "esAlert",
        html: a,
        title: c || "系统提示",
        btnBar: true,
        cancelBtn: false,
        height: 170,
        onOK: function () {
            if (typeof d === "function") {
                return d()
            }
        },
        onXclick: function () {
            if (typeof d === "function") {
                return d()
            }
        }
    };
    if (frameElement && frameElement.lhgDG) {
        window.top.oDGAlert = ES.CRM.openChildPop(b)
    } else {
        window.top.oDGAlert = new $.dialog(b)
    }
    window.top.oDGAlert.ShowDialog();
    return window.top.oDGAlert
};
ES.CRM.openConfirm = function (e, b, c, a) {
    b = '<p style="margin:15px;">' + (b || "") + "</p>";
    var d = {
        id: "esConfirm",
        html: b,
        title: e || "系统提示",
        btnBar: true,
        height: 170,
        onCancel: function () {
            if (typeof a === "function") {
                return a()
            }
        },
        onXclick: function () {
            if (typeof a === "function") {
                return a()
            }
        },
        onOK: function () {
            if (typeof c === "function") {
                return c()
            }
        }
    };
    if (frameElement && frameElement.lhgDG) {
        window.top.oDGConfirm = ES.CRM.openChildPop(d)
    } else {
        window.top.oDGConfirm = new $.dialog(d)
    }
    window.top.oDGConfirm.ShowDialog();
    return window.top.oDGConfirm
};
ES.CRM.showSystemMsg = function (b, a) {
    var c = b == "" ? "系统提示" : b;
    ES.CRM.openPop({
        page: a,
        title: c,
        width: 400,
        height: 150
    });
    setTimeout(function () {
        window.top.oDG.cancel()
    },
    3000)
};
ES.CRM.openMsg = function (b, d, a, e) {
    a = '<p style="margin:15px;">' + (a || "") + "</p>";
    var c = {
        time: b,
        id: "esAlerttime",
        html: a,
        title: d || "系统提示",
        btnBar: true,
        cancelBtn: false,
        height: 170,
        onOK: function () {
            if (typeof e === "function") {
                return e()
            }
        },
        onXclick: function () {
            if (typeof e === "function") {
                return e()
            }
        }
    };
    if (frameElement && frameElement.lhgDG) {
        window.top.oDGAlert = ES.CRM.openChildPop(c)
    } else {
        window.top.oDGAlert = new $.dialog(c)
    }
    window.top.oDGAlert.ShowDialog();
    return window.top.oDGAlert
};
ES.CRM.closePop = function (b) {
    b = $.extend({
        isReLoad: false,
        callback: null
    },
    b);
    var a = function () {
        typeof b.callback == "function" && b.callback()
    };
    if (window.top.oDGAlert != null && window.top.oDGAlert.dg != null) {
        window.top.oDGAlert.cancel();
        window.top.oDGAlert = null;
        return
    }
    if (window.top.oDGConfirm != null && window.top.oDGConfirm.dg != null) {
        window.top.oDGConfirm.cancel();
        window.top.oDGConfirm = null;
        return
    }
    if (window.top.oSDG != null && window.top.oSDG.dg != null) {
        b.isReLoad && (window.top.oSWin.location.href = window.top.oSWin.location.href);
        a();
        window.top.oSDG.cancel();
        window.top.oSDG = null;
        return
    }
    if (window.top.oDG != null && window.top.oDG.dg != null) {
        b.isReLoad && (window.top.oWin.location.href = window.top.oWin.location.href);
        a();
        window.top.oDG.cancel();
        window.top.oDG = null;
        return
    }
};
function OpenPop(a) {
    ES.CRM.openPop(a)
}
function OpenChildPop(a) {
    ES.CRM.openChildPop(a)
}
function ChildCallBack(a) {
    a.call(window.top.oDG.dgWin)
}
function OpenAlert(b, a, c) {
    ES.CRM.openAlert(b, a, c)
}
function OpenConfirm(d, b, c, a) {
    ES.CRM.openConfirm(d, b, c, a)
}
function ShowSystemMsg(b, a) {
    ES.CRM.showSystemMsg(b, a)
}
function OpenMsg(b, c, a, d) {
    ES.CRM.openMsg(b, c, a, d)
}
function closePop(a) {
    ES.CRM.closePop(a)
}
$(function () {
    $(".tb-data>tbody>tr, .tb-dg-data>tbody>tr").mouseover(function () {
        $(this).addClass("cur")
    }).mouseout(function () {
        $(this).removeClass("cur")
    });
    $(".tb-data>tbody>tr:odd, .tb-dg-data>tbody>tr:odd").addClass("odd");
    $("#tagPage>li").bind("click",
    function () {
        var a = $(this);
        a.addClass("cur").siblings().removeClass("cur");
        $("#tagData, #tagSearch").hide();
        $("#" + a.attr("rel")).show()
    })
});
var jsUrl = "http://admin.86tc.com";
var imgUrl = "http://admin.86tc.com";
var cssUrl = "http://admin.86tc.com";